use "C:\Users\ibo6\OneDrive - The Pennsylvania State University\Working Papers\Target Hardening\v10 Terrorism and Political Violence\R & R\Analysis\alldyads2.dta", replace

* Selection criteria 
generate s = total > 0 

* TABLE 4A
** Model 18: Soft Targets (simple)
heckman softtot str_intel_log_l a_l suictot_l, select(s = str_intel_log_l a_l pop_log) vce(cluster dyadid)
estimates store t7_soft_simple
** Model 19: Soft Targets (extended)
heckman softtot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t7_soft_extended
** Model 20: Civilian Targets Only (extended)
heckman civitot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t7_civi_extended
** Model 21: Hard Targets (extended)
heckman hardtot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t7_hard_extended
** Model 22: Mlitary Targets Only (extended)
heckman militot str_intel_log_l a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t7_mili_extended

ssc install estout
label variable str_intel_log_l "Hardening (lagged)"
label variable a_l "Success rate against hard targets (lagged)"
label variable suictot_l "Ratio of suicide attacks (lagged)"
label variable coin_deaths_log_l "COIN casualties (lagged)"
label variable inten "Conflict intensity"
label variable epr "Ethnic fractionalization"
label variable ideology "Group ideology"
label variable pop_log "State population"


label define ideology 1 "Ethnonationalist" 2 "Religious" 3 "Leftist" 4 "Other"
label values ideology ideology

esttab t7_soft_simple t7_soft_extended t7_civi_extended t7_hard_extended t7_mili_extended using apptable4A.csv, b(%5.3f) mlabel("Soft" "Soft" "Civilian" "Hard" "Military") se starlevels(* 0.1 ** 0.05 *** 0.01) label noconstant nobaselevels title("Heckman Selection Models of Target Selection in Relevant State-Group Dyads in India, 2004-2016") addnotes("Heckman Selection Models are estimated using full maximum likelihood with Stata's heckman command. The bottom half of the table presents estimations of the selection equation. The selection criteria is whether or not a given relevant state-group dyad experienced at least 1 insurgent attack in a given year. The upper half of the table presents estimations of prevalence of attacks against respective target types. The dependent variables are the ratio of number of attacks against respective target types to total number of attacks committed in a given relevant state-group dyad in a given year. Robust standard errors clustered on relevant state-group dyads are presented in parantheses.")





* TABLE 5A
** Model 25: Interaction of hardening and ideology
heckman softtot c.str_intel_log_l##ib2.ideology a_l suictot_l coin_deaths_log_l inten epr, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t8_hardening_ideology
** Model 26: Interaction of success rate against hard targets and ideology
heckman softtot str_intel_log_l c.a_l##ib2.ideology suictot_l coin_deaths_log_l inten epr, select(s = str_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t8_success_ideology


esttab t8_hardening_ideology t8_success_ideology using apptable5A.csv, b(%5.3f) mlabel("Soft" "Soft" "Soft" "Soft") se starlevels(* 0.1 ** 0.05 *** 0.01) label noconstant nobaselevels title("Heckman Selection Models of Target Selection in Relevant State-Group Dyads in India, 2004-2016") addnotes("Heckman Selection Models are estimated using full maximum likelihood with Stata's heckman command. The bottom half of the table presents estimations of the selection equation. The selection criteria is whether or not a given relevant state-group dyad experienced at least 1 insurgent attack in a given year. The upper half of the table presents estimations of prevalence of attacks against respective target types. The dependent variables are the ratio of number of attacks against respective target types to total number of attacks committed in a given relevant state-group dyad in a given year. Robust standard errors clustered on relevant state-group dyads are presented in parantheses. The reference category for the Group ideology variable is religious-fundementalist groups.")







